/**

This file is part of MaCI/GIMnet.

MaCI/GIMnet is free software: you can redistribute it and/or modify it 
under the terms of the GNU Lesser General Public License as published 
by the Free Software Foundation, either version 3 of the License, or 
(at your option) any later version.

MaCI/GIMnet is distributed in the hope that it will be useful, but WITHOUT 
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 
FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public 
License for more details.

You should have received a copy of the GNU Lesser General Public 
License along with GIMnet. (See COPYING.LESSER) If not, see 
<http://www.gnu.org/licenses/>.

**/
// -*- coding:iso-8859-15 mode: c++ -*-
/** 
 * \file
 * \brief MaCI_Position Player for logged data
 * \author Matthieu Myrsky <matthieu.myrsky@tkk.fi>
 *
 * $Id: PositionFilePlayer.hpp,v 1.7 2009-11-13 15:11:18 morsko Exp $
 *
 */
#ifndef _POSITIONFILEPLAYER_HPP_
#define _POSITIONFILEPLAYER_HPP_
#include <string>
#include <map>
#include "PlayerModule.hpp"
#include "owndebug.h"
#include "ownutils.h"
#include "gimutils.h"
#include "PositionServer.hpp"
#include "PositionFileReader.hpp"
class PositionFilePlayer: public PlayerModule
{
public:


  PositionFilePlayer(MaCI::Position::CPositionServer *aPosServer,
                      std::string aFilename);

  virtual ~PositionFilePlayer();


  
  bool GetTimes(std::list<gim::time> *aTimes);

 
  bool OnTime(gim::time aTime);


  std::string GetName(void);

  void GetTimeLimits(gim::time &aBegin,gim::time &aEnd);
private:
  bool ReadData();
  CPositionFileReader iReader;
  MaCI::Position::CPositionServer *iPosServer;
  std::map<gim::time,MaCI::Position::CPositionData *> iData;
  std::list<gim::time> iTimes;
  gim::time iBegin;
  gim::time iEnd;
  FILE *iFile;
  std::string iName;

  bool iContainsTimestamp;
  bool iContainsPosition;
  bool iContainsVariance;
  bool iContainsProbability;
  bool iContainsSpeed;
  //*****************************************************************************
  PositionFilePlayer(const PositionFilePlayer&)
    :PlayerModule(),
     iReader(),
     iPosServer(NULL),
     iData(),
     iTimes(),
     iBegin(),
     iEnd(),
     iFile(NULL),
     iName(""),
     iContainsTimestamp(false),
     iContainsPosition(false),
     iContainsVariance(false),
     iContainsProbability(false),
     iContainsSpeed(false){}

  PositionFilePlayer &operator=(const PositionFilePlayer&) { return *this; }
  //*****************************************************************************
};

#endif
